package com.bestcem.xm.award.service.impl;

import com.alibaba.fastjson.JSON;
import com.bestcem.xm.award.mq.dto.ProjectUpdatedDTO;
import com.bestcem.xm.award.service.ProjectUpdatedService;
import com.bestcem.xm.award.service.mq.send.AwardMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 发送项目更新消息实现
 *
 * @author sh.pei <sh.pei@idiaoyan.com>
 * @version v3.0
 * @date 2021/8/23 17:15
 */
@Slf4j
@Service("projectUpdatedService")
public class ProjectUpdatedServiceImpl implements ProjectUpdatedService {

//    @Autowired
//    private RabbitMqMessageSender rabbitMqMessageSender;

//    @Autowired
//    private RabbitMqConstantConfig rabbitMqConstantConfig;

    @Resource
    private AwardMessageService awardMessageService;


    @Override
    public void sendProjectUpdatedMsg(String projectId) {
        ProjectUpdatedDTO projectUpdatedDTO = new ProjectUpdatedDTO();
        projectUpdatedDTO.setProjectId(projectId);
        if (log.isInfoEnabled()) {
            log.info("发送项目更新消息:{}", JSON.toJSONString(projectUpdatedDTO));
        }
        awardMessageService.qdesProjectUpdatedSend(projectUpdatedDTO);
//        try {
//            if (log.isInfoEnabled()) {
//                log.info("发送项目更新消息:{}", JSON.toJSONString(projectUpdatedDTO));
//            }
//          rabbitMqMessageSender.sendMsg(rabbitMqConstantConfig.getAppFanoutExchange(), null, AwardMqConstant.PROJECT_UPDATED_TOPIC, projectUpdatedDTO);
//
//        } catch (JsonProcessingException e) {
//            log.error("[award] mq消息发送失败{}", projectId, e);
//        }
    }
}
